/*
 * Copyright 2015 Zhongan.com All right reserved. This software is the
 * confidential and proprietary information of Zhongan.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Zhongan.com.
 */
package com.zhongan.gateway.web.controller;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.zhongan.gateway.bean.ApiRequestLog;
import com.zhongan.gateway.common.constant.GwDeveloperApiConstant;
import com.zhongan.gateway.service.LogService;
import com.zhongan.gateway.web.common.BaseController;
import com.zhongan.gateway.web.common.PageDTO;

/***
 * 测试用的Controller
 * 
 * @author
 */
@Controller
@RestController
@Configuration
@RequestMapping("/log")
public class LogController extends BaseController {

    //    private Logger logger = LoggerFactory.getLogger(TestController.class);

    @Resource
    private LogService logService;

    @RequestMapping("/getLogs")
    public String selectPageLogs(String serviceName, String appkey, String uuid, String timeStart, String timeEnd,
                                 Integer start, Integer limit) {

        PageDTO<ApiRequestLog> page = logService.selectPageLogs(serviceName, appkey, uuid, timeStart, timeEnd, start,
                limit);
        String re = JSONObject.toJSONStringWithDateFormat(page, GwDeveloperApiConstant.LOG_TIME_FORMAT,
                SerializerFeature.WriteDateUseDateFormat);
        return re;
    }

}
